export default {
  StoreAttendanceSetting: {
    entity: { name: 'AttendanceSetting', prefix: () => `store/${localStorage.getItem('storeId')}` },
    list: {
      list_display: [
        'id',
        { property: 'type', label: '班次' },
        {
          property: 'phase', label: '类型',
          component: {
            props: ['record'],
            render(h) {
              if (this.record.phase) {
                if (this.record.fromMinute >= 9999) {
                  return <el-tag>缺勤(上班)</el-tag>
                } else {
                  return <el-tag>迟到</el-tag>
                }
              } else {
                if (this.record.fromMinute >= 9999) {
                  return <el-tag type='warning'>缺勤(下班)</el-tag>
                } else {
                  return <el-tag type='warning'>早退</el-tag>
                }
              }
            }
          }
        },
        { property: 'fromMinute', label: '起扣时间(分钟)' },
        { property: 'price', label: '扣罚金额' }
      ]
    },
    form: {
      fields: [
        { property: 'type', field_options: { label: '班次' }},
        {
          property: 'phase',
          field_options: { label: '类型' },
          component: {
            props: ['form', 'property'],
            render(h) {
              return (
                <el-select v-model={this.form[this.property]} filterable placeholder='类型'>{
                  [
                    { label: '早退', value: false },
                    { label: '迟到', value: true }
                  ]
                    .map(type => {
                      return <el-option key={type.value} label={type.label} value={type.value} />
                    })
                }</el-select>
              )
            }
          }
        },
        { property: 'fromMinute', field_options: { label: '起扣时间(分钟)' }},
        { property: 'price', field_options: { label: '扣罚金额' }}
      ]
    }
  }
}

